﻿using System;

namespace _78_确定数组中元素的存在性_数组
{
    class Program
    {
        static void Main(string[] args)
        {
            Student[] 学生 =
            {
                new Student
                {
                    Name="小黄",
                    Course="C++",
                    City="广州"
                },
                new Student
                {
                    Name="小朱",
                    Course="C++",
                    City="广州"
                },
                new Student
                {
                    Name="小李",
                    Course="C++",
                    City="广州"
                },
                new Student
                {
                    Name="小赵",
                    Course="C++",
                    City="重dd庆"
                },
                new Student
                {
                    Name="小孙",
                    Course="C#",
                    City="广州"
                }
            };

            //调用Exists方法确认是否有来自重庆的学员
            bool 找重庆 = Array.Exists(学生, x => x.City == "重庆");
            if (找重庆)
            {
                Console.WriteLine("存在重庆来的学员");
            }
            else
            {
                Console.WriteLine("不存在重庆来的学生员");
            }

            Console.WriteLine("\n\n------------按学员名称查找----------");
            bool 找学生名字 = Array.Exists(学生, x => x.Name == "小黄");
            if (找学生名字) Console.WriteLine("小黄同学来报道了");
            else Console.WriteLine("哪有这个名字的学生！");
        }
    }

    public class Student
    {
        public string Name { get; set; }
        public string City { get; set; }
        public string Course { get; set; }
    }

}
